home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 05 Laramée / Listing1.cpp
Encoding:
Text File  |  2001-12-09  |  994 b   |  30 lines

  1. /* Copyright (C) Franτois Dominic LaramΘe, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Franτois Dominic LaramΘe, 2001"
  9.  */
  10.  
  11. const int numLegalMoves = 20;
  12. int Trigram[ numLegalMoves ][ numLegalMoves ][ numLegalMoves ];
  13.  
  14. // Act if the probabibility that A follows BA is high enough...
  15. if( Trigram[ B ][ A ][ A ] > some threshold )
  16.     do something;
  17.  
  18. // To find the most probable next move given that we know what the
  19. // player has done recently...
  20. topScore = MINUS_INFINITY;
  21. for( int i = 0; i < numLegalMoves; i++ )
  22. {
  23.     if( Trigram[ slightlyOlderMove ][ mostRecentMove ][ i ] > topScore )
  24.     {
  25.         topScore = Trigram[ slightlyOlderMove ][ mostRecentMove ][ i ];
  26.         probableNextMove = i;
  27.     }
  28. }
  29.  
  30.